/*******************************************************************
 *
 * Copyright (C), 2021-2022, LS, All rights reserved.
 *
 * Author      : 
 * Create Time : 2021-10-26
 * Version     : v0.1
 * Description : 
 *******************************************************************/

#ifndef _LS_BLE_QUEUE_H_
#define _LS_BLE_QUEUE_H_

#include "stdint.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
    void * buf;
    volatile uint8_t size;
    volatile uint8_t offset;
    volatile uint8_t rd_ptr;
    volatile uint8_t wr_ptr;
    volatile uint8_t used;
} ls_ble_queue_t;

uint8_t ls_ble_queue_init(ls_ble_queue_t *q, void *buf, uint8_t size, uint8_t elem_size);
uint8_t ls_ble_enqueue(ls_ble_queue_t *q, void *in);
uint8_t ls_ble_queue_get(ls_ble_queue_t *q, void *out);
uint8_t ls_ble_dequeue(ls_ble_queue_t *q, void *out);
void ls_ble_queue_decrease(ls_ble_queue_t *q);
void ls_ble_queue_flush(ls_ble_queue_t *q);
uint8_t ls_ble_get_queue_used(ls_ble_queue_t *q);

#ifdef __cplusplus
}
#endif

#endif //_LS_BLE_QUEUE_H_
